package com.bdqn.service.impl;

import com.bdqn.mapper.SupplierMapper;
import com.bdqn.pojo.Supplier;
import com.bdqn.service.SupplierService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("supplierService")
public class SupplierServiceImpl implements SupplierService {
    @Resource
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> getSupplierList(String supCode, String supName, Integer pageIndex, int pageSize) {
        pageIndex = (pageIndex-1)*pageSize;
        return supplierMapper.getSupplierList(supCode,supName,pageIndex,pageSize);
    }

    @Override
    public int getSupplierCount(String supCode, String supName) {
        return supplierMapper.getSupplierCount(supCode,supName);
    }

    @Override
    public int getSupplierAdd(Supplier supplier) {
        return supplierMapper.getSupplierAdd(supplier);
    }

    @Override
    public Supplier getSupplierId(String  id) {
        return supplierMapper.getSupplierId(id);
    }

    @Override
    public boolean getUpdate(Supplier supplier) {
        boolean f = true;
        if (supplierMapper.getUpdate(supplier) != 1) {
            f = false;
        }
        return f;
    }

    @Override
    public List<Supplier> getAllList() {
        return supplierMapper.getAllList();
    }

    @Override
    public boolean delSupplier(Long id) {
        boolean f = false;
        if (supplierMapper.delSupplier(id) > 0){
            f = true;
        }
        return f;
    }
}
